using System.Drawing;
using System.IO;
using System.Windows.Forms;
using DrawTools.Editor;
using DrawTools.Editor.CanvasFigures;
using DrawTools.Properties;

namespace DrawTools.Tools
{
  /// <summary>
  ///   Line tool
  /// </summary>
  public class ArrowTool : ObjectTool
  {
    private readonly EditorColorSettrings _settings;

    public ArrowTool(EditorColorSettrings settings)
    {
      _settings = settings;
      Cursor = new Cursor(new MemoryStream(Resources.Line1));
    }

    public override void OnMouseDown(IDrawingCanvas canvas, MouseEventArgs e)
    {
      var line = new CanvasArrow(e.X, e.Y, e.X + 1, e.Y + 1)
      {
        BorderColor = _settings.BorderColor,
        LineType = LineType.Dash
      };

      AddNewObject(canvas, line);
    }

    public override void OnMouseMove(IDrawingCanvas canvas, MouseEventArgs e)
    {
      canvas.SetCursor(Cursor);

      if (e.Button == MouseButtons.Left)
      {
        var point = new Point(e.X, e.Y);
        canvas.GraphicsList[0].MoveHandleTo(point, 3);
        canvas.Refresh();
      }
    }
  }
}